import request from '@/utils/request.js'

let postDelayTask = null;
let timer = null;
const postWithDelay = function(url, data, delay, fn) { // post防抖方法
	postDelayTask && postDelayTask.abort();
	if (timer) {
	  clearTimeout(timer);
	}
	timer = setTimeout(() => {
	  postDelayTask = request.post(url, data);
	  postDelayTask.then(res => fn(res));
	}, delay);
}


export default postWithDelay
